<template>
    <div class="container" cycleBoard>
        <div class="flex" style="justify-content:space-between">
            <r-text text="政策看板"></r-text>
            <div class="tabWrapper">
                <div :class="[{'tab': currIndex != index}, {'tab-active': currIndex == index}]" v-for="(item, index) in tabs" :key="index" @click="onTabClick(index)">
                    {{item}}
                </div>
            </div>
        </div>
        <div class="header flex">
            <div style="width: 15%">发布时间</div>
            <div style="width: 65%">政策名称</div>
            <div style="width: 20%;text-align:center">政策细则</div>
        </div>
        <div style="height:180px;overflow: auto">
        <div class="table flex" v-for="(item, index) in data" :key="index">
            <div style="width: 15%">{{item.policyDay}}</div>
            <div style="width: 65%;overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">{{item.policyName}}</div>
            <div style="width: 20%;text-align:center; cursor:pointer; color: #64E6E2;" @click="showpdf(index)">查看详情</div>
        </div>
        </div>
      <el-dialog :visible.sync="dialogVisible"  width="1500px" :modal-append-to-body="false"
                 top="62px" style="z-index: 999999999">
<!--        <div  class="title">政策细则</div>-->
        <div class="dialogbox">
          <embed :src="pdfsrc" type="application/pdf"  style="width: 1360px; height: 800px;overflow: hidden">

        </div>

      </el-dialog>
    </div>
</template>
<script>
import RText from '../RText.vue'

export default {
    components: { RText },
    data() {
        return {
            tabs: ['企业政策', '人才政策'],
            currIndex: 0,
            dialogVisible:false,
            pdfsrc:'',
            data: [],
            grdata:[{
              policyDay: '22.02.23',
              policyName: '如政策名称显示不如政策名称显示不如政策名称显示不',
            }],
            qydata:[{
              policyDay: '22.02.23',
              policyName: '如政策名称显示不如政策名称显示不如政策名称显示不',
            }],
        }
    },
    mounted() {

        this.resetData()
        this.initData()
        setInterval(() => {
            this.resetData()
            this.initData()
        }, 60*1000);
    },
    methods: {
      showpdf(num){
        this.dialogVisible=true
        this.pdfsrc = this.data[num].policySrc
         // this.pdfsrc='/bigscreen/static/pdf/zhongjiejigou.pdf'
      },
        onTabClick(index) {
            this.currIndex = index;

            this.initData()
        },
        resetData() {

            let params = {};
            let url = '/dyrl/screen/query/hyzs'
            //let url='/jhApi/dsb/getSa02';
            console.log('调用接口');
            this.$api.commonPost(url, params).then(res => {
                if (res.data.code === 0) {
                    this.grdata = res.data.result.grdata;
                    this.qydata = res.data.result.qydata;


                } else {
                    console.log("error:");
                    this.$message({
                        type: 'error',
                        message: res.data.code,
                        duration: 1500
                    })
                }

            })
        },
        initData() {
            if(this.currIndex==0){
                console.log('qydata');
                this.data=this.qydata
                this.data = [{
                policyDay: '20.09.30',
                policyName: '《东阳市企业“飞地”引才补贴实施细则》',
                policySrc:'/bigscreen/static/pdf/feidiyincai.pdf'
                }]
            }else{
                console.log('grdata');
                this.data=this.grdata
                this.data = [{
                    policyDay: '22.03.31',
                    policyName: '《东阳市人才住房保障实施细则》',
                    policySrc:'/bigscreen/static/pdf/rencaizhufang.pdf'
                },{
                    policyDay: '22.02.23',
                    policyName: '《东阳市引进人才补贴实施细则》',
                    policySrc:'/bigscreen/static/pdf/yingjinrencaibutie.pdf'
                },{
                    policyDay: '22.02.23',
                    policyName: '《东阳市技能人才倍增工程实施细则》',
                  policySrc:'/bigscreen/static/pdf/jinengrencaibeizeng.pdf'

                },{
                    policyDay: '22.02.23',
                    policyName: '《东阳市人才培育奖励实施细则》',
                  policySrc:'/bigscreen/static/pdf/rencaipeiyujiangli.pdf'

                },{
                    policyDay: '22.02.23',
                    policyName: '《东阳市新经济和新社会组织引才奖励实施细则》',
                  policySrc:'/bigscreen/static/pdf/xinjingji.pdf'

                },{
                    policyDay: '22.02.23',
                    policyName: '《东阳市企业人才集合年金补助实施细则》',
                  policySrc:'/bigscreen/static/pdf/jihenianjin.pdf'

                },{
                    policyDay: '22.02.23',
                    policyName: '《东阳市人才交流活动交通和食宿补贴实施细则》',
                    policySrc:'/bigscreen/static/pdf/jiaotongshibu.pdf'

                },{
                    policyDay: '22.02.23',
                    policyName: '《东阳市中介机构引才奖励实施细则》',
                    policySrc:'/bigscreen/static/pdf/zhongjiejigou.pdf'

                },{
                    policyDay: '22.02.23',
                    policyName: '《东阳市“引才联络站”奖励实施细则》',
                    policySrc:'/bigscreen/static/pdf/yincailianluo.pdf'

                },{
                    policyDay: '22.02.23',
                    policyName: '《东阳市博士后工作站奖励实施细则》',
                    policySrc:'/bigscreen/static/pdf/boshihou.pdf'

                },{
                    policyDay: '22.02.23',
                    policyName: '《东阳市引进人才津贴实施细则》',
                    policySrc:'/bigscreen/static/pdf/yinjinrencaijintie.pdf'

                },{
                    policyDay: '22.02.23',
                    policyName: '《东阳市人才大礼包实施细则》',
                    policySrc:'/bigscreen/static/pdf/dalibao.pdf'

                },{
                    policyDay: '22.02.23',
                    policyName: '《东阳市人力资源服务产业园晋级资助实施细则》',
                    policySrc:'/bigscreen/static/pdf/renlifuwu.pdf'

                }]
            }

             /*this.data = [{
                policyDay: '22.02.23',
                policyName: '如政策名称显示不fdfd',
            },{
                policyDay: '22.02.23',
                 policyName: '如政策名称显示不fdfd',
            },{
                policyDay: '22.02.23',
                 policyName: '如政策名称显示不fdfd',
            },{
                policyDay: '22.02.23',
                 policyName: '如政策名称显示不fdfd',
            }]*/
        }
    }

}
</script>
<style lang="less" scoped>

/deep/ .el-dialog {
  background: #032040;

  &__body {
    padding: 10px 20px 20px;
  }
}
.container[cycleBoard]{

    box-sizing: border-box;
}
.flex {
    display: flex;
    align-items: center;

}
.tabWrapper {
    display: flex;
    position: relative;
    padding-right: 20px;
    padding-left: 20px;
    margin-top: 20px;
    margin-bottom: 20px;
    box-sizing: border-box;
    cursor: pointer;
}
.tab {
    font-family: PingFangSC-Regular;
    font-size: 16px;
    color: #FFFFFF;
    width: 160px;
    letter-spacing: 0.96px;
    text-align: center;
    font-weight: 400;
    border: 1px solid rgba(4,74,143,1);
    padding: 4px 0;
    text-align: center;
    flex: 1;

    &-active {
        font-family: PingFangSC-Regular;
        font-size: 16px;
        color: #FFFFFF;
        letter-spacing: 0.96px;
        text-align: center;
        font-weight: 400;
        border: 1px solid rgba(100,230,226,1);
        padding: 4px 0;
        text-align: center;
        flex: 1;
        color: #64E6E2;
    }
}
.header {
    background: rgba(8,132,255,0.32);
    height: 32px;
    text-align: left;
    div {
        padding-left: 10px;
    }
}
.table {
    background: rgba(8,132,255,0.04);
    height: 28px;
    text-align: left;
    div {
        padding-left: 10px;
        white-space: nowrap;
        text-overflow: ellipsis;
        opacity: 0.72;
    }
}
.title{
  font-size:20px;
  text-align: center;
  color:#fff;
}
.dialogbox{
  padding: 0 40px;
  height: 880px;
  overflow: auto;
  P{
    line-height: 24px;
    text-indent: 2em;
    text-align: left;
    color:#fff;
  }
}
</style>
